import request from './request'
import { PageResDto, PageDto, FileUrlDto, ReportCaseResultDto } from '@/api/dto'
// import { PageDto, PageResDto } from '@/api/dto'
import { GetInsureCompleteDto } from '@/api/reminder'
import { number } from '@intlify/core-base'
import * as buffer from 'buffer'
export interface GetAchievementReportDto {
  ele: {
    customerCount: number
    eleCount: number
    eleRechargeCount: string | null
  },
  pay: {
    amount: null | string
    customer: number
    deal: number
  },
  wesure: {
    amount: number
    customerCount: number
    wesureFrequency: number
  },
  period: {
    addCount: number
    customer: number
    premium: number
  }
}

export interface MethodStatisticsDto {
  color: string
  premium: number
  programme: string
  totalPremium: number
  insureCompanyType?: string
}

export interface OperateDataDto {
  integer: number
  openCount: number
  rechargeAmount: number
  rechargeAndUse: number
  insureCompanyType?: string
}

export interface InsuranceDetailDto {
  businessPrincipal: string
  companyId: string
  insuredDate: string
  numberofinsured: number
  premium: number
}

// 业绩报表
export function getAchievementReport (data: { startTime: string, endTime: string }): Promise<GetAchievementReportDto> {
    return request.get('/api/v1/crm/sign-contract-record/get-performance-report', data)
}

// 日日保业绩
// 保险数据
export function getInsureData (data: any): Promise<any> {
    return request.get('/api/v1/crm/sign-contract-record/get-wesure-data', data)
}

// 日日保业绩
// 保险专业版
export function getInsurePlanData (data: void): Promise<string[]> {
    return request.get('/api/v1/crm/sign-contract-record/get-wesure-plan-name')
}
export function getgcpaInsurePlanData (data: any): Promise<string[]> {
    return request.get('/api/v1/crm/sign-contract-record/get-ty-plan-name', data)
}
// 日日保业绩
// 发薪方式统计
export function getMethodStatistics (data: { queryMonth: string }): Promise<MethodStatisticsDto> {
    return request.get('/api/v1/crm/sign-contract-record/get-wesure-programme-count', data)
}

// 日日保业绩
// 运营数据
export function getOperateData (data: { startTime: string, endTime: string }): Promise<OperateDataDto> {
    return request.get('/api/v1/crm/sign-contract-record/get-wesure-operate-data', data)
}

// 日日保业绩
// 全部保司接口
export function getDayAllCompany (type: any): Promise<OperateDataDto> {
    return request.get('/api/v1/crm/sign-contract-record/insure-company?type=' + type)
}

// 日日保业绩
// 近7日开通趋势
export function getDredgeCurrent (data: any): Promise<any> {
    return request.get('/api/v1/crm/sign-contract-record/get-open-seven-days', data)
}

// 日日保业绩
// 投保明细
export function getInsuranceDetail (data: any): Promise<any> {
    return request.get('/api/v1/crm/sign-contract-record/get-wesure-details', data)
}

// 长期保保业绩
// 获取长期保保司
export function getLongCompany (data: void): Promise<any> {
    return request.get('/api/v1/crm/sign-contract-record/get-insurance-company')
}

// 长期保保业绩
// 长期保投保方式
export function getLongPlanData (data: void): Promise<{ insuranceMethod: string, metho: string }[]> {
    return request.get('/api/v1/crm/sign-contract-record/get-period-insurance-method')
}

// 长期保业绩
// 保单列表
export function getLongInsuranceDetail (data: any): Promise<any> {
    return request.get('/api/v1/crm/sign-contract-record/get-policy-list', data)
}

// 长期保业绩
// 加减保
export function getAddSubtract (data: { startTime: string | number, type: number | string, endTime: number, operationType: number | string, searchText: string, pageNum: number, pageSize: number }): Promise<any> {
    return request.get('/api/v1/crm/sign-contract-record/get-add-and-subtract-insur', data)
}

// 长期保业绩
// 获取长期保保险方案
export function getLongInsurancePlan (data: void): Promise<InsuranceDetailDto> {
    return request.get('/api/v1/crm/sign-contract-record/get-period-plan')
}

// 长期保业绩
// 总保费
export function getLongAllCount (data: { insurCompany: string | number | null, insurCompanyPlanCode: string | number, startTime: string, endTime: string, insuranceMethod: number | string }): Promise<any> {
    return request.get('/api/v1/crm/sign-contract-record/get-period-data', data)
}

// 长期保业绩
// 其他数据
export function getLongOhterData (data: { insurCompany: string | number | null }): Promise<any> {
    return request.get('/api/v1/crm/sign-contract-record/get-period-other-data', data)
}

// 长期保业绩
// 运营数据
export function getLongOperateData (data: { startTime: string, endTime: string, insuranceMethod: number | string }): Promise<any> {
    return request.get('/api/v1/crm/sign-contract-record/get-period-operate-data', data)
}

// 长期保业绩
// 风险类别统计（按人数）
export function getLongStatistics (data: { queryMonth: string | number }): Promise<any> {
    return request.get('/api/v1/crm/sign-contract-record/get-risk-category-by-people', data)
}

// 长期保业绩
// 风险类别统计（按金额）
export function getLongAtMoney (data: { queryMonth: string | number }): Promise<any> {
    return request.get('/api/v1/crm/sign-contract-record/get-risk-category-by-money', data)
}

// 长期保业绩
// 近7日加减保趋势
export function getLongTrend (data: void): Promise<any> {
    return request.get('/api/v1/crm/sign-contract-record/get-add-and-reduce-trend')
}

// 长期保业绩
// 近7日开通趋势
export function getLongOpenTrend (data: void): Promise<any> {
    return request.get('/api/v1/crm/sign-contract-record/get-pay-open-nearly-seven')
}

// 子弹发薪业绩
// 销售数据
export function getAchievementData (data: { startTime: string, endTime: string }): Promise<any> {
    return request.get('/api/v1/crm/sign-contract-record/get-pay-sale-achievement', data)
}

// 子弹发薪业绩
// 运营数据 项目统计
export function getProjectStatistics (data: { startTime: string, endTime: string, insuranceMethod: number | string }): Promise<any> {
    return request.get('/api/v1/crm/sign-contract-record/get-pay-operate', data)
}

// 子弹发薪业绩
// 近7日趋势
export function getSenvenTrend (data: void): Promise<any> {
    return request.get('/api/v1/crm/sign-contract-record/get-pay-nearly-seven')
}

// 子弹发薪业绩
// 发薪方式统计(按笔数)
export function getAchievementMethodStatistics (data: { queryMonth: string }): Promise<any> {
    return request.get('/api/v1/crm/sign-contract-record/get-pay-mode-by-quantity', data)
}

// 子弹发薪业绩
// 发薪方式统计(按金额)
export function getAchievementMethodStatisticsAmount (data: { queryMonth: string }): Promise<any> {
    return request.get('/api/v1/crm/sign-contract-record/get-pay-mode-by-amount', data)
}

// 子弹发薪业绩
// 销售明细
export function getVenditionInsuranceDetail (data: { salesScenario: number | string, pageNum: number, pageSize: number, searchText: string, startTime: string, endTime: string, sortOrder: string | number }): Promise<any> {
    return request.get('/api/v1/crm/sign-contract-record/get-pay-detailed', data)
}

// 子弹发薪业绩
// 退款明细startTime，endTime，queryTime，sortOrder
export function getRefundmentDetail (data: { pageNum: number, pageSize: number, startTime: string, endTime: string, sortOrder: string | number }): Promise<any> {
    return request.get('/api/v1/crm/sign-contract-record/get-refund-details', data)
}

// 电子签业绩
// 销售数据
export function getEleSaleData (data: { startTime: string, endTime: string }): Promise<any> {
    return request.get('/api/v1/crm/sign-contract-record/get-ele-sales-data', data)
}

// 电子签业绩
// 运营数据
export function getEleOperateData (data: { startTime: string, endTime: string, insuranceMethod: number | string }): Promise<any> {
    return request.get('/api/v1/crm/sign-contract-record/get-ele-operate-data', data)
}

// 电子签业绩
// 近7日充值趋势
export function getEleSevenRechargeTrend (data: void): Promise<any> {
    return request.get('/api/v1/crm/sign-contract-record/get-ele-recharge-nearly-seven')
}

// 电子签业绩
// 近7日签署趋势
export function getEleSevenSignTrend (data: void): Promise<any> {
    return request.get('/api/v1/crm/sign-contract-record/get-ele-sign-trend')
}

// 电子签业绩
// 充值明细
export function getEleRechargeDetail (data: { pageNum: number, pageSize: number, startTime: string, endTime: string, sortOrder: string | number, searchText: string }): Promise<any> {
    return request.get('/api/v1/crm/sign-contract-record/get-ele-recharge-details', data)
}

// 我的客户
export function getMyClient (data: { productType: number | string, sortOrder: string | number, searchText: string, pageNum: number, pageSize: number }): Promise<any> {
    return request.get('/api/v1/crm/product-deal/get-my-customer', data)
}

// 其他数据统计
export function getOtherData (data: void): Promise<any> {
    return request.get('/api/v1/crm/product-deal/get-other-data')
}

// 客户池
export function getClientPond (data: { pageNum: number, pageSize: 50, productType: number | string, searchText: string }): Promise<any> {
    return request.get('/api/v1/crm/product-deal/get-customer-pool', data)
}

// 团意保相关接口

// /crm/record/query-all-company   快捷中心-客户池

export function getqueryallcompanyaapi (params: any) {
    return request.get('/api/v1/crm/sign-contract-record/query-all-company', params)
}
